package com.suncnpap.library.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.app.util.database.mybatis.Page;
import com.suncnpap.library.service.BorrowBookService;
import com.suncnpap.library.mapper.BorrowBookMapper;
import com.suncnpap.library.model.BorrowBook;
import com.suncnpap.library.model.BorrowBookInfo;
import com.suncnpap.library.model.BorrowBookRecord;

/** 
 * 说明： 图书借阅Service实现类
 * @version
 */
@Service("borrowBookService")
public class BorrowBookServiceImpl implements BorrowBookService{

	
	@Autowired
	BorrowBookMapper borrowBookMapper;
	
	@Override
	public void add(BorrowBook obj) {
		// TODO Auto-generated method stub
		borrowBookMapper.add(obj);
	}

	@Override
	public void update(BorrowBook obj) {
		// TODO Auto-generated method stub
		borrowBookMapper.edit(obj);
	}

	@Override
	public void deleteById(String strId) {
		// TODO Auto-generated method stub
		borrowBookMapper.deleteById(strId);
		
	}
	@Override
	public void deleteMore(String[] strIds) {
		// TODO Auto-generated method stub
		borrowBookMapper.deleteMore(strIds);
	}

	@Override
	public Page list(Page page) {
		// TODO Auto-generated method stub
		List<BorrowBook> list = borrowBookMapper.datalistPage(page);
		page.setDataList(list);
		return page;
	}


	@Override
	public int findCount(Page page) {
		// TODO Auto-generated method stub
		return borrowBookMapper.findCount(page);
	}

	@Override
	public BorrowBook findById(String strId) {
		// TODO Auto-generated method stub
		return borrowBookMapper.findById(strId);
	}
	
	@Override
	public void deleteByBookBarcode(String strBookBarcode, String strSchoolId){
		borrowBookMapper.deleteByBookBarcode(strBookBarcode, strSchoolId);
	}
	
	@Override
	public int findCountByCardNumber(String strCardNumber, String strSchoolId){
		return borrowBookMapper.findCountByCardNumber(strCardNumber, strSchoolId);
	}
	
	@Override
	public Page listInfo(Page page) {
		// TODO Auto-generated method stub
		List<BorrowBookInfo> list = borrowBookMapper.dataInfolistPage(page);
		page.setDataList(list);
		return page;
	}
	
	@Override
	public  void addList(List<BorrowBook> objList){
		if(objList!=null && objList.size()>0){
			for(BorrowBook reader:objList){
				if(reader!=null){
					borrowBookMapper.add(reader);
				}
			}
		}
		
	}
	
	@Override
	public BorrowBook findByBookBarcode(String strBookBarcode, String strSchoolId) {
		// TODO Auto-generated method stub
		return borrowBookMapper.findByBookBarcode(strBookBarcode, strSchoolId);
	}
}

